/*
 * PopupCanvassChoice.hpp
 *
 *  Created on: Jul 17, 2012
 *      Author: guillou
 */

#ifndef POPUPCANVASSCHOICE_HPP_
#define POPUPCANVASSCHOICE_HPP_

#include <ui_choice.h>
#include <PopupCanvassWidget.hpp>

class PopupChoiceWidget : public QWidget, private Ui_ChoiceWidget
{
  Q_OBJECT

public:
  virtual ~PopupChoiceWidget() {}
  PopupChoiceWidget(QWidget *p_parent = 0,
                    unsigned short p_choiceIndex = 0,
                    const std::string & p_choiceLabel = "")
  : QWidget(p_parent), m_parent((PopupCanvassWidget*)p_parent), m_choiceIndex(p_choiceIndex)
  {
    setupUi(this);
    pushButton->setText(p_choiceLabel.c_str());
    connect(pushButton, SIGNAL(toggled(bool)),
            this, SLOT(slot_choiceToggled(bool)));
  }

  void unselect() {
    pushButton->setChecked(false);
    checkBox->setChecked(false);
  }

  inline unsigned short index() { return m_choiceIndex; }

private slots:
  void slot_choiceToggled(bool p_status) {
    m_parent->onChoiceToggled(this, p_status);
  }

private:
  PopupCanvassWidget *m_parent;
  unsigned short m_choiceIndex;
};

#endif /* POPUPCANVASSCHOICE_HPP_ */
